﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using AltimilliaLibrary.State;
using AltimilliaLibrary.Intelligence;
using AltimilliaLibrary.Dialog;

namespace AltimilliaLibrary
{
  public class NPC : Sprite
  {
    public SpriteScript SScript { get; set; }
    public DialogComponent DialogCompon { get; set; }

    public NPC(Point TilePosition, Sprite.Facing Facing, float maxSpeed, AnimationData animdata, SpriteScript sscript)
      : base(TilePosition, Facing, maxSpeed, animdata)
    {
      this.SScript = sscript;

    }

    public NPC(Point TilePosition, Sprite.Facing Facing, float maxSpeed, AnimationData animdata)
      : base(TilePosition, Facing, maxSpeed, animdata)
    {
    }

    public void DisplayDialog(bool enabled)
    {
      this.DialogCompon.Enabled = enabled;
    }

    private Point OriginalPosition;
    //comment


    public override void Initialize()
    {
      OriginalPosition = this.TilePosition;
      this.State = WalkDown.GetInstance();
      this.DialogCompon = new DialogComponent(this.spriteManager.batch, this.spriteManager.game.Content);
      this.DialogCompon.Initialize();
      base.Initialize();
    }

    public override void Draw(GameTime gameTime)
    {
      if(this.DialogCompon.Enabled)
        this.DialogCompon.Draw(gameTime);
      base.Draw(gameTime);
    }

    public override void Update(GameTime gameTime)
    {
      this.SScript.Execute(this);
      //Test
      //Choose Left as direction
      //I want to reach 8 paces in that direction
      //Whats my orginal position?
      //Better, whats my destination. Have the destination be the idea.

      //SScript.Execute(this);

      //walk left 8 paces
      //if (this.TilePosition.X > OriginalPosition.X - 8)
      //{
      //    this.ChangeDirection(AltimilliaLibrary.State.WalkDirection.WalkLeft);
      //    MoveDirection(WalkDirection.WalkLeft);
      //}
      base.Update(gameTime);
    }
  }
}
